import request from "@/request/request";
import requestMock from "@/request/requestMock";
//1. 请求三级分类列表
export const reqCategoryList = () => {
  return request.get("/product/getBaseCategoryList");
};

//2. 请求轮播图的mock数据
export const reqBannerList = () => {
  return requestMock.get("/home/banner");
};

//3. 请求首页的floor数据
export const reqFloorList = () => {
  return requestMock.get("/home/floor");
};

// 4.请求搜索页数据
export const reqSearchList = (searchParams) => {
  return request.post("/list", searchParams);
};
// 5.请求某个商品的详情数据
export const reqGoodDetail = (skuId)=>{
  return request.get(`/item/${skuId}`);
};
// 6.添加购物车和对已有商品数量修改
export const reqAddCartOrUpdataCart = (skuId, skuNum) => {
  return request.post(`/cart/addToCart/${skuId}/${skuNum}`);
};
// 7.获取购物车列表
export const reqCartList=()=>{
  return request.get(`/cart/cartList`);
};
// 8.删除购物车数据
export const deleteCartList =(skuId)=>{
  return request.delete(`/cart/deleteCart/${skuId}`);
};
//9. 修改单个状态
export const changeChecked = (skuId, isChecked) => {
  return request.get(`/cart/checkCart/${skuId}/${isChecked}`);
};
//10.批量选中购物车
export const changeAllChecked = (isChecked, skuIdList) => {
  return request.post(`/cart/batchCheckCart/${isChecked}`, skuIdList);
};

//11. 删除所有的选中的商品
export const reqDeleteAllCart = (skuIdList) => {
  return request.delete(`/cart/batchDeleteCart`, {
    data: skuIdList,
  });
}
//12. 获取验证码
export const reqVerifyCode = (phone) => {
  return request.get(`/user/passport/sendCode/${phone}`);
}
// 13.注册
export const reqRegister=(userInfo)=>{
  return request.post(`/user/passport/register`,userInfo)
}
//14. 登录
export const reqLogin = (userInfo) => {
  return request.post(`/user/passport/login`, userInfo);
}
//15. 请求用户信息（需要携带token）
export const reqUserInfo = ()=>{
  return request.get(`/user/passport/auth/getUserInfo`)
}
// 16.退出登录
export const reqLogout =()=>{
  return request.get(`/user/passport/logout`)
}
// 17.请求用户地址的mock数据
export const reqAddress =()=>{
  return requestMock.get(`/user/userAddress/auth/findUserAddressList`)
}
//18.请求交易页数据信息
export const reqTradeInfo = ()=>{
  return request.get(`/order/auth/trade`);
}
// 19.请求订单编号
export const reqOrderNo = (tradeNo,tradeDetail)=>{
  return request.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`,tradeDetail)
}
//20.根据订单号 得到完整的支付信息
export const reqPayInfo = (orderId) => {
  return request.get(`/payment/weixin/createNative/${orderId}`)
}
// 21.查询订单检查支付状态
export const reqPayState = (orderId)=>{
  return request.get(`/payment/weixin/queryPayStatus/${orderId}`)
}

//22.获取订单的分页列表
export const reqOrderList = ({page,limit})=>{
  return request.get(`/order/auth/${page}/${limit}`)
}
